<template>
    <el-form ref="form" :model="form" label-width="80px" class="form">
      <el-form-item label="原始密码">
        <el-input type="password" v-model="form.password" disabled class="store_input"></el-input>
      </el-form-item>
      <el-form-item label="新 密 码">
        <el-input type="password" v-model="form.pass" class="store_input"></el-input>
      </el-form-item>
      <el-form-item label="确认密码">
        <el-input type="password" v-model="form.respass" class="store_input"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">确认</el-button>
      </el-form-item>
</el-form>
</template>
 
<script>
export default {
  name: 'storePass',
  data() {
    return {
      form: {
      }
    }
  },
  created: function() {
    this.getInfo()
  },
  methods: {
    getInfo:function(){
      var data = {store_id:localStorage.getItem('store_id')}
      var that = this
      this.$get('store/pass',data).then((res) => {
        that.form = res.data
      })
    },
    onSubmit:function(){
      if(!this.form.pass){
        this.$message.error('请输入新密码');
        return;
      }
      if(!this.form.respass){
        this.$message.error('请输入确认密码');
        return;
      }
      if(this.form.respass !== this.form.pass){
        this.$message.error('两次密码输入不一致');
        return;
      }
      var that = this
      var data = {id:this.form.id,password:this.form.pass}
      this.$post('store/savePass',data).then((res) => {
          if(res.code == 1){
            that.$message.success(res.msg);
            // localStorage.removeItem('store_id')
            // localStorage.removeItem('user_id')
            // localStorage.removeItem('name')
            // localStorage.removeItem('logo')
            // localStorage.removeItem('expireTime')
            // localStorage.removeItem('user_name')
            // that.$router.push({ path: "/login" });
          }else{
            that.$message.error(res.msg);
          }
      })
    }
  }
}
</script>
<style>
.form{
  padding:20px 20px 20px 20%;
  justify-content:center;
}
.store_input {
  width:350px !important;
}
.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 120px;
    height: 120px;
    line-height: 120px;
    text-align: center;
  }
  .avatar {
    width: 120px;
    height: 120px;
    display: block;
  }
</style>